var app = getApp()
var IP = app.globalData.IP
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //订单id
    id:'',
    selected: '',
    serviceid: '',
    imageurl: '',
    servicename: '',
    // 故障列表
    breakdown: [],
    activebutton: '',
    buttonid: '',
    selectedguzhang:{},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    //接收eventChannel传来的数据
    const eventChannel = this.getOpenerEventChannel()
    var that = this
    eventChannel.on('data', function (data) {
      that.setData({
        selected: data.selected + '>',
        serviceid: data.serviceid,
        imageurl: data.imageurl,
        servicename: data.servicename,
        id:data.id
        
      })
      console.log(data)
    })

    this.getparts()

  },
  click(e) {
    this.setData({
      activebutton: 'background-color: #65bec7',
      buttonid: e.currentTarget.dataset.buttonid
    })

    wx.navigateTo({
      url: '/pages/taximeter/detail4/detail4',
      success: res => {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('data', {
          selected: this.data.selected + e.currentTarget.dataset.selected,
          serviceid: this.data.serviceid,
          imageurl: this.data.imageurl,
          servicename: this.data.servicename,
          selectedguzhang:e.currentTarget.dataset.item,
          id:this.data.id,

        })
      }
    })

  
  },
  getparts() {
    wx.request({
      url: `http://${IP}:8080/employee/getparts`,
      data: {
        serviceid: this.data.serviceid,
        category: '故障'
      },
      success: res => {
        this.setData({
          breakdown: res.data
        })
      }
    })
  },




})